package bb.lanxing.lib.devices.ble.device;

import android.bluetooth.BluetoothGattCharacteristic;
//import com.alipay.sdk.packet.d;
import bb.lanxing.lib.devices.api.SmartDevice;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleCharacteristic;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleSensorDevice;
import bb.lanxing.lib.devices.ble.ble.base.BaseResponsiveCharacteristic;
import bb.lanxing.lib.devices.ble.ble.characteristic.SensorLocation;
import bb.lanxing.lib.devices.ble.ble.characteristic.SensorLocationCharacteristics;
import bb.lanxing.lib.devices.ble.ble.interfaces.SensorLocationController;
import bb.lanxing.lib.devices.ble.ble.services.BatteryService;
import bb.lanxing.lib.devices.ble.ble.services.CSCBleService;
import bb.lanxing.lib.devices.ble.ble.services.DisBleService;
import bb.lanxing.lib.devices.ble.ble.services.XossCmdService;
import bb.lanxing.lib.devices.ble.switchablecadence.SwitchableCadenceController;
import bb.lanxing.lib.devices.core.dfu.ICDMDfuDevice;
import bb.lanxing.lib.devices.core.dfu.IDfuAdapter;
import bb.lanxing.lib.devices.core.dfu.IDfuDevice;
//import bb.lanxing.lib.devices.sprint.Command;
//import bb.lanxing.lib.devices.sprint.Commands;
//import bb.lanxing.lib.devices.sprint.SimpleBleDeviceDfuAdapter;
//import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: CyclingSpeedAndCadenceDevice.kt */

public final class CyclingSpeedAndCadenceDevice extends BaseBleSensorDevice implements  SensorLocationController {
    public static final Companion Companion = new Companion(null);
    public static final int TYPE_CADENCE = 1;
    public static final int TYPE_SPEED = 0;
    private final BatteryService batteryService;
    private CSCBleService cscBleService;
    private IDfuAdapter dfuAdapter;
    private final DisBleService disService;
    private boolean isSwitching;
    private XossCmdService xossCmdService;

    public CyclingSpeedAndCadenceDevice(SmartDevice device) {
        super(device);
        Intrinsics.checkNotNullParameter(device, "device");
        CyclingSpeedAndCadenceDevice cyclingSpeedAndCadenceDevice = this;
        this.cscBleService = new CSCBleService(cyclingSpeedAndCadenceDevice);
        this.batteryService = new BatteryService(cyclingSpeedAndCadenceDevice);
        this.disService = new DisBleService(cyclingSpeedAndCadenceDevice);
        this.xossCmdService = new XossCmdService(cyclingSpeedAndCadenceDevice);
    }

    public CSCBleService getCscBleService() {
        return this.cscBleService;
    }

    public void setCscBleService(CSCBleService cSCBleService) {
        Intrinsics.checkNotNullParameter(cSCBleService, "<set-?>");
        this.cscBleService = cSCBleService;
    }

    public BatteryService getBatteryService() {
        return this.batteryService;
    }

    public DisBleService getDisService() {
        return this.disService;
    }

    public XossCmdService getXossCmdService() {
        return this.xossCmdService;
    }

    public void setXossCmdService(XossCmdService xossCmdService) {
        Intrinsics.checkNotNullParameter(xossCmdService, "<set-?>");
        this.xossCmdService = xossCmdService;
    }

    /*@Override
    public IDfuAdapter getDfuAdapter() {
        if (this.dfuAdapter == null) {
            this.dfuAdapter = new SimpleBleDeviceDfuAdapter(this.mAppContext, this);
        }
        return this.dfuAdapter;
    }*/

    public BluetoothGattCharacteristic getCDMService() {
        BaseResponsiveCharacteristic baseResponsiveCharacteristic = this.xossCmdService.getXossResponsiveCharacteristic();
        if (baseResponsiveCharacteristic != null) {
            BaseBleCharacteristic baseBleCharacteristic = baseResponsiveCharacteristic.getCmdCharacteristics();
            if (baseBleCharacteristic != null)
                return baseBleCharacteristic.getRawCharacteristic();
        }
        return null;
    }
   /* @Override
    public BluetoothGattCharacteristic getCDMService() {
        BaseBleCharacteristic cmdCharacteristics;
        BaseResponsiveCharacteristic xossResponsiveCharacteristic = this.xossCmdService.getXossResponsiveCharacteristic();
        if (xossResponsiveCharacteristic == null || (cmdCharacteristics = xossResponsiveCharacteristic.getCmdCharacteristics()) == null) {
            return null;
        }
        return cmdCharacteristics.getRawCharacteristic();
    }*/

    /*@Override
    public boolean switchTo(int i) {
        BaseResponsiveCharacteristic xossResponsiveCharacteristic = this.xossCmdService.getXossResponsiveCharacteristic();
        boolean z = false;
        if (xossResponsiveCharacteristic != null) {
            Command create = Commands.create(48, new byte[]{(byte) i});
            Intrinsics.checkNotNullExpressionValue(create, "create(Commands.SWITCHAB…teArrayOf(type.toByte()))");
            z = xossResponsiveCharacteristic.sendCommand(create);
        }
        this.isSwitching = z;
        return z;
    }*/

    public static final class Companion {
        public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }

    @Override
    public SensorLocation getSensorLocation() {
        SensorLocationCharacteristics sensorLocationCharacteristics = this.cscBleService.getSensorLocationCharacteristics();
        if (sensorLocationCharacteristics != null) {
            return sensorLocationCharacteristics.getSensorLocation();
        }
        return null;
    }
}
